<template>
  <div class="admin_all">
    <admin_top></admin_top>
    <div style="padding: 0 20px;">
      <div class="flex">
        <el-input v-model="order_id" placeholder="订单ID"></el-input>
        <el-input v-model="source_id" placeholder="外部订单号"></el-input>
        <el-input v-model="plan_mobile_produced" placeholder="生产号码查询"></el-input>
        <el-input v-model="id_card_num" placeholder="身份证查询"></el-input>
        <el-input v-model="address_mobile" placeholder="联系电话查询"></el-input>
        <el-button size="mini" type="danger" @click="getlist">搜索</el-button>
      </div>

      <div class="kflex">
        <div v-for="(item,index) in alllist" :key="index">
          <div style="margin: 10px 20px 10px 0; font-weight: bold; cursor: pointer;" @click="allindex = index" :class="allindex == index?'act':''">{{item.order_info.order_id}}</div>
        </div>
      </div>

      <div class="zu" v-if="alllist != ''">
        <div class="tit">自动生产订单</div>
        <div class="con" v-for="item in alllist[allindex].upstream_order" :key="item.order_id">
            <span style="margin-right: 20px;">对接渠道：{{item.account}} </span>
            <span style="margin-right: 20px;">用户自定义渠道名称：{{item.user_defined_name}} </span>
            <span style="margin-right: 20px;">订单id：{{item.order_id}} </span>
            <span style="margin-right: 20px;">查询状态：{{item.query_status}} </span>
            <span style="margin-right: 20px;">查询类型：{{item.query_type}} </span>
            <span style="margin-right: 20px;">失败原因：{{item.reason}} </span>
            <span style="margin-right: 20px;">上游订单状态：{{item.status}} </span>
            <span style="margin-right: 20px;">上游订单号：{{item.upstream_order_id}} </span>
            <span style="margin-right: 20px;">是否放弃：{{item.upstream_status}} </span>
        </div>
      </div>
      <div class="zu" v-if="alllist != ''">
        <div class="tit">后台记录</div>
        <div class="con">

          <div>发货物流信息:物流公司：{{alllist[allindex].order_info.tracking_company}}物流单号：{{alllist[allindex].order_info.tracking_number}}</div>
          <div>是否激活:{{alllist[allindex].order_info.active_name}}</div>
          <div>生产号码:{{alllist[allindex].order_info.plan_mobile_produced}}</div>



          <div v-for="(item,index) in alllist[allindex].admin_log" :key="index" class="flex">
            <div class="lli">操作人：{{item.name}}</div>
            <div class="lli">时间：{{item.created_at}}</div>
            <div class="lli">事情：{{item.log_info}}</div>
            <div class="lli" style="max-width: 600px;">
              <div>记录：{{item.remark}}</div>
            </div>
          </div>

        </div>
      </div>
      <div class="zu" v-if="alllist != ''">
        <div class="tit">基础信息</div>
        <div class="con">
          <div class="flex">
            <div class="lli">商品名称:{{alllist[allindex].order_info.title}}</div>
            <div class="lli">所属商家:{{alllist[allindex].order_info.user_name}}</div>
            <div class="lli">所属店铺:{{alllist[allindex].order_info.source}}</div>
            <div class="lli">商品编码:{{alllist[allindex].order_info.fetch_code}}</div>
          </div>
          <div class="flex">

            <div class="lli">订单创建时间:{{alllist[allindex].order_info.created_at}}</div>
            <div class="lli">下单时间:{{alllist[allindex].order_info.ordered_at}}</div>
            <div class="lli">状态更新时间:{{alllist[allindex].order_info.status_updated_at}}</div>
          </div>
          <div class="flex">

            <div class="lli">订单操作记录:{{alllist[allindex].order_info.seller_memo}}</div>
          </div>
          <div class="flex">

            <div class="lli">产品渠道:{{alllist[allindex].order_info.product_name}}</div>
            <div class="lli">产品编码:{{alllist[allindex].order_info.sku}}</div>
          </div>
          <div class="flex">

            <div class="lli" v-if="alllist[allindex].order_info.is_owe == 0">是否欠费:否</div>
            <div class="lli" v-if="alllist[allindex].order_info.is_owe == 1">是否欠费:是</div>
            <div class="lli" v-if="alllist[allindex].order_info.is_auto_produce == 0">是否自动生成:不是</div>
            <div class="lli" v-if="alllist[allindex].order_info.is_auto_produce == 1">是否自动生成:是</div>
            <div class="lli">敏感地区:{{alllist[allindex].order_info.warn_area}}</div>

            <div class="lli">订单号:{{alllist[allindex].order_info.order_id}}</div>
            <div class="lli">web单号:{{alllist[allindex].order_info.source_id}}</div>
          </div>
          <div class="flex">
            <div class="lli">订单状态:{{alllist[allindex].order_info.status_name}}</div>
          </div>
        </div>
      </div>
      <div class="zu" v-if="alllist != ''">
        <div class="tit">接口日志</div>
        <div class="con" v-for="(item,index) in alllist[allindex].auto_produce_log" :key="index">

          <div class="lli">提交接口:{{item.channel_name}}</div>
          <div class="lli">数据列表:{{item.data}}</div>
          <div class="lli">入参:{{item.input}}</div>
          <div class="lli">出参:{{item.output}}</div>
          <div class="lli">类型:{{item.type}} <span style="margin-left: 30px; color: #999;">(0提单1回调2查单3其他)</span></div>
          <div class="lli">状态:{{item.status}} <span style="margin-left: 30px; color: #999;">(0返回正常-1返回异常)</span></div>
          <div class="lli">备注:{{item.summary}}</div>
          <div class="lli">创建时间:{{item.created_at}}</div>
          <div class="lli">显示状态:{{item.status_name}}</div>
          <div class="lli">日志显示文案:<span v-html="item.show"></span></div>

        </div>
      </div>
      <div class="zu" v-if="alllist != ''">
        <div class="tit">分销关系</div>
        <div class="con">
          {{alllist[allindex].commission}}
        </div>
      </div>
      <div class="zu" v-if="alllist != ''">
        <div class="tit">正在运行的队列</div>
        <div class="con">
          <div v-for="(item,index) in alllist[allindex].job" :key="index" class="flex">
            <div class="lli">任务：{{item.queue}}</div>
          </div>
        </div>
      </div>
      <div class="zu" v-if="alllist != ''">
        <div class="tit">分销设置</div>
        <div class="con">
          <div class="flex">

            <div class="lli">分销商可见:{{alllist[allindex].order_info.visible_name}}</div>
            <div class="lli">佣金规则:{{alllist[allindex].order_info.commission_rule}}</div>
            <div class="lli">佣金:{{alllist[allindex].order_info.commission}}</div>
          </div>
          <div>
            <div v-for="(item,index) in alllist[allindex].order_info.shop_list" :key="index">
              <div>
                {{item.name}}{{item.commission}}{{item.rule}}
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="zu" v-if="alllist != ''">
        <div class="tit">分销继承</div>
        <div class="con">
          <div class="flex">

            <div class="lli">基于产品:{{alllist[allindex].order_info.product_name}}</div>
            <div class="lli">分销关系:{{alllist[allindex].goods_retail}}</div>
          </div>
        </div>
      </div>
      <div class="zu" v-if="alllist != ''">
        <div class="tit">抓单记录</div>
        <div class="con">
          暂无
        </div>
      </div>
      <div class="zu" v-if="alllist != ''">
        <div class="tit">生产方操作记录</div>
        <div class="con">
          {{alllist[allindex].order_info.producer_memo}}
        </div>
      </div>
      <div class="zu" v-if="alllist != ''">
        <div class="tit">发展方操作记录</div>
        <div class="con">
          {{alllist[allindex].order_info.seller_memo}}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import admin_top from './top.vue';
  import axios from "axios";
  export default {
    components: {
      admin_top
    },
    name: "admin_all",
    data() {
      return {
        order_id: "",
        source_id: "",
        id_card_num:"",
        plan_mobile_produced:"",
        address_mobile:'',
        all: "",
        alllist: "",
        allindex:0
      };
    },
    created() {

    },
    methods: {
      go: function(url) {
        this.$router.push(url)
      },
      getlist: function() {
        axios.get(`/api/plan-market/admin/order/info?order_id=${this.order_id}&source_id=${this.source_id}&id_card_num=${this.id_card_num}&plan_mobile_produced=${this.plan_mobile_produced}&address_mobile=${this.address_mobile}`)
          .then(response => {
            if (response.data.msg.code == 0) {
              this.allindex = 0
              this.alllist = response.data.data
            } else {
              this.$message.error(response.data.msg.info);
            }
          });
      }
    }
  };
</script>

<style lang="scss" scoped>
  .admin_all {
    background: #EAEAEA;
    min-height: 100vh;
    box-sizing: border-box;

    .logo {
      height: 30px;
    }
    .act{ color: #f00;}
    .el-input {
      width: 250px;
      margin-right: 10px;
    }

    .flex {
      display: flex;
    }


    .zu {
      margin-top: 20px;

      .tit {
        background: #ccc;
        line-height: 45px;
        padding-left: 20px;
      }

      .con {
        background: #FFFFFF;
        padding: 20px;
        line-height: 30px;
        font-size: 14px;
      }

      .lli {
        margin-right: 30px;
        color: #666;
      }
    }
  }
</style>
